<?php
/**
 * 用户收货地址模型
 * @author maniac
 */
namespace app\common\model;

class MemberAddresses extends SoftDel
{
    public $insert = ['create_time'];

    /**
     * 创建时间修改器
     * @param string $value 字段值
     */
    public function setCreateTimeAttr($value)
    {
        return time();
    }


    /**
     * 获取省份
     * @param string $value 字段值
     * @param string $data  数据
     */
    public function getProvinceTxtAttr($value,$data)
    {
        $where = [
            'region_id' => $data['province']
        ];
        $info = Zoning::field('region_name')->where($where)->find();
        return $info['region_name'];
    }


    /**
     * 获取城市
     * @param string $value 字段值
     * @param string $data  数据
     */
    public function getCityTxtAttr($value,$data)
    {
        $where = [
            'region_id' => $data['city']
        ];
        $info = Zoning::field('region_name')->where($where)->find();
        return $info['region_name'];
    }

    /**
     * 获取区县
     * @param string $value 字段值
     * @param string $data  数据
     */
    public function getDistrictTxtAttr($value,$data)
    {
        $where = [
            'region_id' => $data['district']
        ];
        $info = Zoning::field('region_name')->where($where)->find();
        return $info['region_name'];
    }
}
